﻿@using DiplomaWeb.Models.Student
@model DiplomaWeb.Models.CompaniesAndLecturers.CompanyPropertiesViewModel
@using (Html.BeginRouteForm("Default", new { controller = "SystemManagers", action = "UpdateCompanyProperties" }))
{
    <div id="divCompanyProperties">
        @Html.HiddenFor(r => r.Id)
        <div style="margin-bottom: 20px;">@Html.EditorFor(r => r.Name)</div>
        @for (int i = 0; i < Model.Levels.Count; i++)
        {
            <div style="margin-bottom: 20px;">
                <div class="largeText">@Model.Levels[i].Name</div>
                <div>
                    @Html.HiddenFor(r => r.Levels[i].Id)
                    @Html.EditorFor(r => r.Levels[i].IsCheck)
                    @Html.EditorFor(r => r.Levels[i].MaxStudents)
                </div>
                @if (Model.Levels[i].Students != null)
                {
                    <table>
                        @foreach (StudentViewModel s in Model.Levels[i].Students)
                        {
                            <tr>
                                <td>@s.FIO</td>
                                <td>@s.GroupName</td>
                            </tr>
                        }
                    </table>
                    <div class="largeText">Total students: @Model.Levels[i].Students.Count()</div>
                    if (Model.Levels[i].MaxStudents.HasValue && Model.Levels[i].MaxStudents.Value < Model.Levels[i].Students.Count())
                    {
                        <div class="largeText" style="color: red;">Limit exceeded</div>
                    }
                }
            </div>
        }
        <div>
            <input type="submit" value="Update" />
        </div>
    </div>
}